<%@page import="Interface.Entity"%>
<%@page import="session.SessionInterface"%>
<%@page import="GUI.LanguageLoader"%>
<%@page import="GUI.EntityGUI"%>
<%
            String name = request.getParameter("entity");
            String id = request.getParameter("id");
            LanguageLoader language = new LanguageLoader();
            SessionInterface sessione = new SessionInterface();
            Entity e;
            EntityGUI eGUI;

            if (id != null) {
                if (null != session.getAttribute("username")) {
                    e = new EntityGUI(name, session.getAttribute("username").toString(), session.getAttribute("gruppo").toString());
                } else {
                    e = new EntityGUI(name);
                }
                eGUI = (EntityGUI) e;
                eGUI.setAttributeValueSuperMode(e.getPrymaryKeyName(), id);
                e = sessione.load(e);
                eGUI = (EntityGUI) e;

                String attributeName[];
                attributeName = e.getAllNameAttribute();

%>

<h1><%= id%></h1>
<h2><%= name%></h2>

<%
                String value;
                for (int i = 0; i < attributeName.length; i++) {
                    value = e.getAttributeValueToString(attributeName[i]);
                    if (!value.equals("ReadNotPermits")) {
                        out.print("<h3>" + language.getCaption(name, attributeName[i]) + "</h3>");
                        out.print("<div>" + value);
                        if (eGUI.isPermitsModify(attributeName[i])) {
                            out.print(" - (<a href=\"#\" onclick=\"loadMod(\'"+ name +"\',\'"+ attributeName[i] +"\')\">" + language.getSysCaption("modifyAttribute") + "</a>)");
                        }
                        out.print(" </div>");
                        out.print("<div class='descrizione'>" + language.getDescription(name, attributeName[i]) + "</div>");
                    }
                }
            }
%>